home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / src / PHP / php.exe / Count Down.php < prev    next >
Encoding:
PHP Script  |  2001-07-03  |  2.8 KB  |  80 lines

  1.     //**************************************
  2.     //     
  3.     // Name: Count Down
  4.     // Description:Gives a date/time count d
  5.     //     own between current date/time and future
  6.     //     date/time.
  7.     // By: Tom Gard
  8.     //
  9.     // Inputs:current date
  10.     future date
  11.     //
  12.     // Returns:count of:
  13.     days
  14.     hours
  15.     minutes
  16.     seconds
  17.     //
  18.     // Assumes:I am new to learning php and 
  19.     //     was looking for some code that I could p
  20.     //     ut a count down type of thing on my webs
  21.     //     ite. After searching around and not real
  22.     //     ly finding what I was looking for I came
  23.     //     up with this code. It works pretty well 
  24.     //     I guess. I'd appreciate any feedback, pe
  25.     //     rhaps there is a better way to get a cou
  26.     //     nt down, if so send me a clue. Thanks
  27.     //
  28.     //This code is copyrighted and has    // limited warranties.Please see http://
  29.     //     www.Planet-Source-Code.com/xq/ASP/txtCod
  30.     //     eId.250/lngWId.8/qx/vb/scripts/ShowCode.
  31.     //     htm    //for details.    //**************************************
  32.     //     
  33.     
  34.     <?php
  35.     //Count Down of Days:Hours:Minutes:Secon
  36.     //     ds
  37.     //by T.Gard (tom_g@execpc.com) written 0
  38.     //     1/09/2001
  39.     //
  40.     //Date/Time counting down too.
  41.     $datetime=strtotime( "2001-01-27 11:00" );
  42.     //Retrieve the current date/time 
  43.     $date2=strtotime("NOW"); 
  44.     if ($datetime < $date2) {
  45.     print "The Event is here!! or over with!! <br> ".$date2." is greater than ".$datetime."<br>";
  46.     } else {
  47.     //List total time by type
  48.     //Seconds
  49.     echo "total seconds remaining: ".(($datetime-$date2)). "<br>";
  50.     $holdtotsec=(($datetime-$date2));
  51.     //Minutes
  52.     echo "total minutes remaining: ".(($datetime-$date2)/60). "<br>";
  53.     $holdtotmin=(($datetime-$date2)/60);
  54.     //Hours
  55.     echo "total hours remaining: ".(($datetime-$date2)/3600). "<br>";
  56.     $holdtothr=(($datetime-$date2)/3600); 
  57.     //
  58.     //Days - a day is a 24 hour period
  59.     //This gives days remaining
  60.     $holdtotday=intval(($datetime-$date2)/86400);
  61.     echo "total days remaining: ".$holdtotday. "<br>"; 
  62.     //
  63.     //Find hours remaining - get days in hou
  64.     //     rs and sub from tothr
  65.     $holdhr=intval($holdtothr-($holdtotday*24));    
  66.     echo "hours remaining: ".($holdhr). "<br>";
  67.     //
  68.     //Find minutes remaining - get days and 
  69.     //     hours in minutes and sub from totmin
  70.     $holdmr=intval($holdtotmin-(($holdhr*60)+($holdtotday*1440))); 
  71.     echo "minutes remaining: ".($holdmr). "<br>";
  72.     //
  73.     //Find seconds remaining - get days hour
  74.     //     s minutes in seconds and sub from totsec
  75.     //     
  76.     $holdsr=intval($holdtotsec-(($holdhr*3600)+($holdmr*60)+(86400*$holdtotday))); 
  77.     echo "seconds remaining: ".($holdsr). "<br>";
  78.     }
  79.     ?>
  80.